package org.gap.web.jsf;

import java.util.List;

import org.gap.dao.RolesDAO;
import org.gap.dao.RolesTiersDAO;
import org.gap.dao.TiersDAO;

import org.gap.domain.Roles;
import org.gap.domain.RolesTiers;
import org.gap.domain.Tiers;

import org.gap.service.RolesTiersService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.annotation.Scope;

import org.springframework.stereotype.Component;

import org.springframework.transaction.annotation.Transactional;

/**
 * Spring Component that handles CRUD requests for RolesTiers entities
 * 
 */
@Scope("session")
@Component("RolesTiersComponent")
public class RolesTiersComponentImpl implements RolesTiersComponent {

	/**
	 * Data type variable that provides CRUD operations for RolesTiers entities
	 * 
	 */
	private RolesTiers rolestiers;

	/**
	 * DAO injected by Spring that manages Tiers entities
	 * 
	 */
	private Tiers tiers;

	/**
	 * DAO injected by Spring that manages Roles entities
	 * 
	 */
	private Roles roles;

	/**
	 * DAO injected by Spring that manages Roles entities
	 * 
	 */
	@Autowired
	private RolesDAO rolesDAO;

	/**
	 * DAO injected by Spring that manages RolesTiers entities
	 * 
	 */
	@Autowired
	private RolesTiersDAO rolesTiersDAO;

	/**
	 * DAO injected by Spring that manages Tiers entities
	 * 
	 */
	@Autowired
	private TiersDAO tiersDAO;

	/**
	 * Service injected by Spring that provides CRUD operations for RolesTiers entities
	 * 
	 */
	@Autowired
	private RolesTiersService rolesTiersService;

	/** 
	 */
	public RolesTiersComponentImpl() {
	}

	/**
	 * Select the RolesTiers entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteRolesTiers(String rotRoleKey, Integer rotTiersKey) {
		rolestiers = rolesTiersDAO.findRolesTiersByPrimaryKey(rotRoleKey, rotTiersKey);

		return "/jsf/rolestiers/deleteRolesTiers.xhtml";
	}

	/**
	 * View an existing Tiers entity
	 * 
	 */
	@Transactional
	public String selectRolesTiersTiers(String rolestiers_rotRole, Integer rolestiers_rotTiers, Integer related_tiers_tieTiers) {
		tiers = tiersDAO.findTiersByPrimaryKey(related_tiers_tieTiers, -1, -1);
		return "/jsf/rolestiers/tiers/viewTiers.xhtml";
	}

	/**
	 * Save an existing Roles entity
	 * 
	 */
	@Transactional
	public String saveRolesTiersRoles(String rolestiers_rotRole, Integer rolestiers_rotTiers, Roles roles) {
		rolestiers = rolesTiersService.saveRolesTiersRoles(rolestiers_rotRole, rolestiers_rotTiers, roles);

		return "/jsf/rolestiers/viewRolesTiers.xhtml";
	}

	/**
	 * Getter for variable RolesTiers
	 * 
	 */
	@Transactional
	public RolesTiers getRolestiers() {
		return rolestiers;
	}

	/**
	 * Getter for variable RolesTiers
	 * 
	 */
	@Transactional
	public Tiers getTiers() {
		return tiers;
	}

	/**
	 * View an existing Roles entity
	 * 
	 */
	@Transactional
	public String selectRolesTiersRoles(String rolestiers_rotRole, Integer rolestiers_rotTiers, String related_roles_rolRole) {
		roles = rolesDAO.findRolesByPrimaryKey(related_roles_rolRole, -1, -1);
		return "/jsf/rolestiers/roles/viewRoles.xhtml";
	}

	/**
	 * Show all RolesTiers entities
	 * 
	 */
	@Transactional
	public List<RolesTiers> listRolesTierss() {
		return new java.util.ArrayList<RolesTiers>(rolesTiersService.loadRolesTierss());
	}

	/**
	 * Get Tiers entity by RolesTiers
	 * 
	 */
	@Transactional
	public Tiers getRolesTiersTiers(String rotRoleKey, Integer rotTiersKey) {
		return rolesTiersDAO.findRolesTiersByPrimaryKey(rotRoleKey, rotTiersKey).getTiers();
	}

	/**
	 * Edit an existing Tiers entity
	 * 
	 */
	@Transactional
	public String editRolesTiersTiers(String rolestiers_rotRole, Integer rolestiers_rotTiers, Integer related_tiers_tieTiers) {
		tiers = tiersDAO.findTiersByPrimaryKey(related_tiers_tieTiers, -1, -1);
		return "/jsf/rolestiers/tiers/editTiers.xhtml";
	}

	/**
	 * Select the child Roles entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteRolesTiersRoles(String rolestiers_rotRole, Integer rolestiers_rotTiers, String related_roles_rolRole) {
		roles = rolesDAO.findRolesByPrimaryKey(related_roles_rolRole);

		return "/jsf/rolestiers/roles/deleteRoles.xhtml";
	}

	/**
	 * Delete an existing RolesTiers entity
	 * 
	 */
	@Transactional
	public String deleteRolesTiers(String rotRoleKey, Integer rotTiersKey) {
		RolesTiers rolestiers = rolesTiersDAO.findRolesTiersByPrimaryKey(rotRoleKey, rotTiersKey);
		rolesTiersService.deleteRolesTiers(rolestiers);
		return "/jsf/rolestiers/listRolesTierss.xhtml";
	}

	/**
	 * Create a new Tiers entity
	 * 
	 */
	@Transactional
	public String newRolesTiersTiers(String rolestiers_rotRole, Integer rolestiers_rotTiers) {
		tiers = new Tiers();

		return "/jsf/rolestiers/tiers/createTiers.xhtml";
	}

	/**
	 * Edit an existing RolesTiers entity
	 * 
	 */
	@Transactional
	public String editRolesTiers(String rotRoleKey, Integer rotTiersKey) {
		rolestiers = rolesTiersDAO.findRolesTiersByPrimaryKey(rotRoleKey, rotTiersKey);

		return "/jsf/rolestiers/editRolesTiers.xhtml";
	}

	/**
	 * Delete an existing Tiers entity
	 * 
	 */
	@Transactional
	public String deleteRolesTiersTiers(String rolestiers_rotRole, Integer rolestiers_rotTiers, Integer related_tiers_tieTiers) {
		rolestiers = rolesTiersService.deleteRolesTiersTiers(rolestiers_rotRole, rolestiers_rotTiers, related_tiers_tieTiers);

		return "/jsf/rolestiers/viewRolesTiers.xhtml";
	}

	/**
	 * Select the child Tiers entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteRolesTiersTiers(String rolestiers_rotRole, Integer rolestiers_rotTiers, Integer related_tiers_tieTiers) {
		tiers = tiersDAO.findTiersByPrimaryKey(related_tiers_tieTiers);

		return "/jsf/rolestiers/tiers/deleteTiers.xhtml";
	}

	/**
	 * Delete an existing Roles entity
	 * 
	 */
	@Transactional
	public String deleteRolesTiersRoles(String rolestiers_rotRole, Integer rolestiers_rotTiers, String related_roles_rolRole) {
		rolestiers = rolesTiersService.deleteRolesTiersRoles(rolestiers_rotRole, rolestiers_rotTiers, related_roles_rolRole);

		return "/jsf/rolestiers/viewRolesTiers.xhtml";
	}

	/**
	 * Create a new RolesTiers entity
	 * 
	 */
	@Transactional
	public String newRolesTiers() {
		rolestiers = new RolesTiers();

		return "/jsf/rolestiers/createRolesTiers.xhtml";
	}

	/**
	 * Save an existing Tiers entity
	 * 
	 */
	@Transactional
	public String saveRolesTiersTiers(String rolestiers_rotRole, Integer rolestiers_rotTiers, Tiers tiers) {
		rolestiers = rolesTiersService.saveRolesTiersTiers(rolestiers_rotRole, rolestiers_rotTiers, tiers);

		return "/jsf/rolestiers/viewRolesTiers.xhtml";
	}

	/**
	 * Getter for variable RolesTiers
	 * 
	 */
	@Transactional
	public Roles getRoles() {
		return roles;
	}

	/**
	 * Save an existing RolesTiers entity
	 * 
	 */
	@Transactional
	public String saveRolesTiers(RolesTiers rolestiers) {
		rolesTiersService.saveRolesTiers(rolestiers);
		return "/jsf/rolestiers/listRolesTierss.xhtml";
	}

	/**
	 * Edit an existing Roles entity
	 * 
	 */
	@Transactional
	public String editRolesTiersRoles(String rolestiers_rotRole, Integer rolestiers_rotTiers, String related_roles_rolRole) {
		roles = rolesDAO.findRolesByPrimaryKey(related_roles_rolRole, -1, -1);
		return "/jsf/rolestiers/roles/editRoles.xhtml";
	}

	/**
	 * Select an existing RolesTiers entity
	 * 
	 */
	@Transactional
	public String selectRolesTiers(String rotRoleKey, Integer rotTiersKey) {
		rolestiers = rolesTiersDAO.findRolesTiersByPrimaryKey(rotRoleKey, rotTiersKey);

		return "/jsf/rolestiers/viewRolesTiers.xhtml";
	}

	/**
	 * Get Roles entity by RolesTiers
	 * 
	 */
	@Transactional
	public Roles getRolesTiersRoles(String rotRoleKey, Integer rotTiersKey) {
		return rolesTiersDAO.findRolesTiersByPrimaryKey(rotRoleKey, rotTiersKey).getRoles();
	}

	/**
	 * Create a new Roles entity
	 * 
	 */
	@Transactional
	public String newRolesTiersRoles(String rolestiers_rotRole, Integer rolestiers_rotTiers) {
		roles = new Roles();

		return "/jsf/rolestiers/roles/createRoles.xhtml";
	}

}
